﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace z.Controllers {
	public class OrderController : Controller {
		//
		// GET: /Order/

		public ActionResult Index() {
			return View();
		}
		public ActionResult Adminster() {
			return View();
		}
		[HttpPost]
		public ActionResult _Adminster(FormCollection fc) {
			using (m.db.Database db = new m.db.Database()/*Goi Database*/) {
				//thao tac vs Database
				//lay Field ID tu Form va Parse thanh int
				int id; int.TryParse(fc.Get("ID"), out id);
				//lay obj order tu database
				var order = db.Orders.Where(x => x.ID == id).Single();
				//luu cac Field tu Form vao obj order(luu y phai Parse neu nhu kg trai la string)
				order.Address = fc.Get("Address");
				db.SaveChanges();
				return PartialView("_Adminster", order);
			}
		}
	}
}
